//
//  HWTixianguanliCell.m
//  HWPromoteProjectAPP
//
//  Created by 陈道斌 on 2020/3/5.
//  Copyright © 2020 陈道斌. All rights reserved.
//

#import "HWTixianguanliCell.h"

@interface HWTixianguanliCell()
@property(strong,nonatomic) NSMutableArray *labelMuArr;
@end


@implementation HWTixianguanliCell
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    
    }

    return  self;
}

// 设置UI
- (void)setupUI {
    
    self.labelMuArr = [[NSMutableArray alloc]init];
    
    
    
    
    
    CGFloat W = kScreenW - 40;
    CGFloat H = 58;
    
     CGFloat meigelabeW = W / 5;
    
    for (int i = 0 ; i < 5; i++) {

            UILabel   *userLabel = [[UILabel alloc]initWithFrame:CGRectMake(meigelabeW*i, 0, meigelabeW, H)];
            userLabel.text = @"";
            userLabel.textAlignment =  NSTextAlignmentCenter;
            userLabel.textColor = RGB(0, 0, 0);
            userLabel.alpha = 0.65;
            userLabel .font = [UIFont systemFontOfSize:12];
            userLabel.hidden = NO;
            userLabel.backgroundColor = RGB(243, 243, 243);
            userLabel.numberOfLines = 2;
            [self.contentView   addSubview: userLabel];
        
        
        
        
            [self.labelMuArr addObject:userLabel];
          
      }
    
    UIView *fengexian =  [[UIView alloc]initWithFrame:CGRectMake(0, 57, W, 1)];
    fengexian.backgroundColor = RGB(232, 232, 232);
    [self.contentView addSubview:fengexian];
    
    for (int i = 0 ; i < 6; i++) {

        UIView *fengexian = [[UIView alloc]initWithFrame:CGRectMake(i*meigelabeW, 0, 1, H)];
        fengexian.backgroundColor = RGB(232, 232, 232);
        [self.contentView addSubview:fengexian];
        fengexian.hidden = NO;
       
        
    }
    
    
    
    UILabel *labe = self.labelMuArr[4];
    labe.userInteractionEnabled = YES;
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame  = CGRectMake( (meigelabeW - 40)/2, 6,  40, 20);
    [button setTitle:@"允许" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    button.backgroundColor = RGB(85, 89, 234);
    button.layer.cornerRadius = 2;
    button.layer.masksToBounds = YES;
    button.userInteractionEnabled = YES;
    [button addTarget:self action:@selector(buttontap) forControlEvents:UIControlEventTouchUpInside];
    button.titleLabel.font = [UIFont systemFontOfSize:12];
    [labe addSubview:button];
   
   
      UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
      button1.frame  = CGRectMake( (meigelabeW - 40)/2, button.bottom+6,  40, 20);
      [button1 setTitle:@"拒绝" forState:UIControlStateNormal];
      [button1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
      button1.backgroundColor = RGB(255, 118, 118);
      button1.layer.cornerRadius = 2;
      button1.layer.masksToBounds = YES;
        button1.userInteractionEnabled = YES;
    
     [button1 addTarget:self action:@selector(buttontap1) forControlEvents:UIControlEventTouchUpInside];
      button1.titleLabel.font = [UIFont systemFontOfSize:12];
      [labe addSubview:button1];
   
    
    
      
    
    
    
}


//- (void)setModel:(MyOfflineModel *)model {
//    
//    
//    _model = model;
//    
//      UILabel *label1 = (UILabel *)self.labelMuArr[0];
//      UILabel *label2 = (UILabel *)self.labelMuArr[1];
//      UILabel *label3 = (UILabel *)self.labelMuArr[2];
//       UILabel *label4 = (UILabel *)self.labelMuArr[3];
//     label1.text  = [NSString stringWithFormat:@"%@",model.username];
//     label2.text  = [NSString stringWithFormat:@"%@",model.phone];
//     label3.text  = [NSString stringWithFormat:@"%@",model.is_login];
//     label4.text  = [NSString stringWithFormat:@"%@",model.fcbl];
//}



- (void)setModel:(HWTixianguanliModel *)model {
    
    _model = model;
    
     UILabel *label1 = (UILabel *)self.labelMuArr[0];
      UILabel *label2 = (UILabel *)self.labelMuArr[1];
      UILabel *label3 = (UILabel *)self.labelMuArr[2];
      UILabel *label4 = (UILabel *)self.labelMuArr[3];
    
     label1.text  = [NSString stringWithFormat:@"%@",model.username];
     label2.text  = [NSString stringWithFormat:@"%@",model.money];
     label3.text  = [NSString stringWithFormat:@"%@",model.create_time];
    
    
     label4.text  = [NSString stringWithFormat:@"%@",model.status];
    
    
    
    
}

// 允许
- (void)buttontap {
    
    [self.delegate HWTixianguanliCellModel:self.model xuanzhongInd:1];
    
}


- (void)buttontap1 {
    
    
    [self.delegate HWTixianguanliCellModel:self.model xuanzhongInd:2];
    
    
}


@end
